package com.example.gokuplayalong.service.fragments.others;


import static com.example.gokuplayalong.R.color.*;

import android.annotation.SuppressLint;
import android.graphics.Color;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.gokuplayalong.MainActivity;
import com.example.gokuplayalong.R;
import com.example.gokuplayalong.bases.alipay.directpay.DirectPay;
import com.example.gokuplayalong.bases.alipay.directpayinterface.DirectPayInterface;
import com.example.gokuplayalong.bases.beans.AppParams;
import com.example.gokuplayalong.bases.beans.Beans;
import com.example.gokuplayalong.bases.custom.UserBaseViewHolder;
import com.example.gokuplayalong.bases.exception.ExceptionUtils;
import com.example.gokuplayalong.bases.network.NetWorkInterface;
import com.example.gokuplayalong.bases.tools.Logger;
import com.example.gokuplayalong.bases.tools.Tools;
import com.example.gokuplayalong.service.fragments.users.profile.UserMainProfileMyOrder;
import com.example.gokuplayalong.service.fragments.users.profile.UserMainProfileMyOrderException;
import com.example.gokuplayalong.service.fragmentsmanage.SysManagerFragments;
import com.huawei.hms.ads.App;
import com.kongzue.dialogx.dialogs.BottomDialog;
import com.kongzue.dialogx.dialogs.BottomMenu;
import com.kongzue.dialogx.dialogs.MessageDialog;
import com.kongzue.dialogx.dialogs.PopTip;
import com.kongzue.dialogx.dialogs.WaitDialog;
import com.kongzue.dialogx.interfaces.OnBindView;
import com.kongzue.dialogx.interfaces.OnDialogButtonClickListener;
import com.kongzue.dialogx.interfaces.OnMenuItemClickListener;
import com.squareup.picasso.MemoryPolicy;
import com.squareup.picasso.NetworkPolicy;
import com.squareup.picasso.Picasso;


import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.Objects;

public class UserMainPageOrderListListViewHolder extends UserBaseViewHolder {
    private LinearLayout mUserMainProfileMyOrderItem;
    private TextView mUserMainProfileMyOrderItemOrdernum;
    private TextView mUserMainProfileMyOrderItemMessage;
    private Button mUserMainProfileMyOrderItemMessageBtn;
    private TextView mUserMainProfileMyOrderItemStatus;
    private LinearLayout mUserMainProfileMyorderDetail;
    private ImageView mUserMainProfileMyOrderItemMerchantHeadshot;
    private TextView mUserMainProfileMyOrderItemGametype;
    private TextView mUserMainProfileMyOrderItemServicetype;
    private TextView mUserMainProfileMyOrderItemStarttime;
    private TextView mUserMainProfileMyOrderItemOrderBalance;
    private Button mUserMainReceiveOrderItemException;
    private Button mUserMainReceiveOrderItemStart;
    private Button mUserMainReceiveOrderItemFinish;
    private Button mUserMainReceiveOrderItemEvaluate;
    private Button mUserMainReceiveOrderItemPay;

    Beans bean = new Beans();
    double orderBalance = 0, originBalance = 0, couponsBalance = 0;
    JSONObject merchantInfo = new JSONObject();

    public static BottomMenu bottomMenu;


    public UserMainPageOrderListListViewHolder(@NonNull View itemView) {
        super(itemView);
        mUserMainProfileMyOrderItem = itemView.findViewById(R.id.user_main_profile_my_order_item);
        mUserMainProfileMyOrderItemMessage = itemView.findViewById(R.id.user_main_profile_my_order_item_message);
        mUserMainProfileMyOrderItemMessageBtn = itemView.findViewById(R.id.user_main_profile_my_order_item_message_btn);
        mUserMainProfileMyOrderItemOrdernum = itemView.findViewById(R.id.user_main_profile_my_order_item_ordernum);
        mUserMainProfileMyOrderItemStatus = itemView.findViewById(R.id.user_main_profile_my_order_item_status);
        mUserMainProfileMyorderDetail = itemView.findViewById(R.id.user_main_profile_myorder_detail);
        mUserMainProfileMyOrderItemMerchantHeadshot = itemView.findViewById(R.id.user_main_profile_my_order_item_merchant_headshot);
        mUserMainProfileMyOrderItemGametype = itemView.findViewById(R.id.user_main_profile_my_order_item_game_type);
        mUserMainProfileMyOrderItemServicetype = itemView.findViewById(R.id.user_main_profile_my_order_item_servicetype);
        mUserMainProfileMyOrderItemStarttime = itemView.findViewById(R.id.user_main_profile_my_order_item_starttime);
        mUserMainProfileMyOrderItemOrderBalance = itemView.findViewById(R.id.user_main_profile_my_order_item_order_balance);
        mUserMainReceiveOrderItemException = itemView.findViewById(R.id.user_main_receive_order_item_exception);
        mUserMainReceiveOrderItemStart = itemView.findViewById(R.id.user_main_receive_order_item_start);
        mUserMainReceiveOrderItemFinish = itemView.findViewById(R.id.user_main_receive_order_item_finish);
        mUserMainReceiveOrderItemEvaluate = itemView.findViewById(R.id.user_main_receive_order_item_evaluate);
        mUserMainReceiveOrderItemPay = itemView.findViewById(R.id.user_main_receive_order_item_pay);

        mUserMainReceiveOrderItemException.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    if (!Tools.Deshak()) return;
                    SysManagerFragments.switchOnSysFragment("UserMainProfileMyOrderException");
                } catch (Throwable e) {
                    ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
                }
            }
        });
        mUserMainReceiveOrderItemPay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {

                    if (!Tools.Deshak()) return;

                    mUserMainProfileMyOrderItem.setBackgroundResource(R.color.bk_1);
                    bottomMenu = BottomMenu.show(new String[]{"支付宝", "取消支付"})
                            .setTitle("请选择支付方式")
                            .setCancelable(false)

                            .setOnMenuItemClickListener(new OnMenuItemClickListener<BottomMenu>() {
                                @Override
                                public boolean onClick(BottomMenu dialog, CharSequence text, int index) {
                                    if (text.equals("支付宝")) {

                                        Beans beansIn = new Beans();
                                        beansIn.getJsonObject()
                                                .put("phone", AppParams.getInstance().appCurrentUser.getJsonObject()
                                                        .getString("phone"));
                                        beansIn.getJsonObject()
                                                .put("ordernum", bean.getJsonObject()
                                                        .getString("ordernum"));
                                        beansIn.getJsonObject()
                                                .put("subject", "悟空陪玩订单支付" + bean.getJsonObject()
                                                        .getString("ordernum"));
                                        beansIn.getJsonObject().put("total_amount", orderBalance);
                                        beansIn.getJsonObject()
                                                .put("merchant_id", merchantInfo.getString("merchantid"));

                                        AppParams.getNewNetWork()
                                                .setInterface(new NetWorkInterface() {
                                                    @Override
                                                    public int success(String msg) {
                                                        try {
                                                            JSONObject msgFromServer = JSON.parseObject(msg);
                                                            if (Objects.equals(msgFromServer.getString("result"), "成功")) {
                                                                beansIn.getJsonObject()
                                                                        .put("out_trade_no", msgFromServer.getString("out_trade_no"));
                                                                DirectPay.getNewDirectPay()
                                                                        .setDirectPayInterface(new DirectPayInterface() {
                                                                            @Override
                                                                            public void success(String msg) {

                                                                                try {
                                                                                    alipayHandler(beansIn);
                                                                                } catch (
                                                                                        Throwable e) {
                                                                                    ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
                                                                                }
                                                                                MainActivity.getInstance()
                                                                                        .runOnUiThread(new Runnable() {
                                                                                            @Override
                                                                                            public void run() {
                                                                                                try {
                                                                                                    if (Objects.equals(bean.getJsonObject()
                                                                                                            .getString("phone"), AppParams.getInstance().appCurrentUser.getJsonObject()
                                                                                                            .getString("phone"))) {

                                                                                                        mUserMainProfileMyOrderItem.setBackgroundResource(R.color.bk);
                                                                                                    }
                                                                                                    else {
                                                                                                        mUserMainProfileMyOrderItem.setBackgroundResource(R.color.white);


                                                                                                    }
                                                                                                } catch (
                                                                                                        Throwable e) {
                                                                                                    ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
                                                                                                }
                                                                                            }
                                                                                        });
                                                                            }

                                                                            @Override
                                                                            public void failed(String msg) {
                                                                                MainActivity.getInstance()
                                                                                        .runOnUiThread(new Runnable() {
                                                                                            @Override
                                                                                            public void run() {
                                                                                                try {
                                                                                                    if (Objects.equals(bean.getJsonObject()
                                                                                                            .getString("phone"), AppParams.getInstance().appCurrentUser.getJsonObject()
                                                                                                            .getString("phone"))) {

                                                                                                        mUserMainProfileMyOrderItem.setBackgroundResource(R.color.bk);
                                                                                                    }
                                                                                                    else {
                                                                                                        mUserMainProfileMyOrderItem.setBackgroundResource(R.color.white);


                                                                                                    }
                                                                                                } catch (
                                                                                                        Throwable e) {
                                                                                                    ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
                                                                                                }
                                                                                            }
                                                                                        });

                                                                            }
                                                                        })
                                                                        .payV2(msgFromServer.getString("orderInfo"), beansIn);
                                                            }
                                                        } catch (Throwable e) {
                                                            ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
                                                        }
                                                        return 0;
                                                    }

                                                    @Override
                                                    public int failed(String msg) {
                                                        return 0;
                                                    }
                                                })
                                                .execute(AppParams.getInstance().baseUrl + "/buildOrderInfo", beansIn.getJsonObject()
                                                        .toJSONString());

                                    }
                                    else if (text.equals("取消支付")) {
                                        MainActivity.getInstance().runOnUiThread(new Runnable() {
                                            @Override
                                            public void run() {
                                                try {
                                                    if (Objects.equals(bean.getJsonObject()
                                                            .getString("phone"), AppParams.getInstance().appCurrentUser.getJsonObject()
                                                            .getString("phone"))) {

                                                        mUserMainProfileMyOrderItem.setBackgroundResource(R.color.bk);
                                                    }
                                                    else {
                                                        mUserMainProfileMyOrderItem.setBackgroundResource(R.color.white);


                                                    }
                                                } catch (Throwable e) {
                                                    ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
                                                }
                                            }
                                        });

                                    }
                                    return false;
                                }
                            });


                } catch (Throwable e) {
                    ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
                }
            }
        });
        mUserMainReceiveOrderItemStart.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    if (!Tools.Deshak(200)) return;
                    WaitDialog.show("请稍后...");
                    Beans beansIn = new Beans();
                    beansIn.getJsonObject()
                            .put("phone", AppParams.getInstance().appCurrentUser.getJsonObject()
                                    .getString("phone"));
                    beansIn.getJsonObject()
                            .put("ordernum", bean.getJsonObject().getString("ordernum"));
                    AppParams.getNewNetWork()
                            .setInterface(new NetWorkInterface() {
                                @Override
                                public int success(String msg) {
                                    try {
                                        JSONObject msgFromServer = JSON.parseObject(msg);
                                        if (Objects.equals(msgFromServer.getString("result"), "成功")) {
                                            Message message = new Message();
                                            message.what = 2;
                                            UserMainProfileMyOrder userMainProfileMyOrder = (UserMainProfileMyOrder) AppParams.getInstance().sysfragmentmanager.findFragmentByTag("UserMainProfileMyOrder");
                                            if (userMainProfileMyOrder != null) {
                                                userMainProfileMyOrder.handler.sendMessage(message);

                                            }
                                        }
                                    } catch (Throwable e) {
                                        ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
                                    }
                                    return 0;
                                }

                                @Override
                                public int failed(String msg) {
                                    return 0;
                                }
                            })
                            .execute(AppParams.getInstance().baseUrl + "/orderStart", beansIn.getJsonObject()
                                    .toJSONString());

                } catch (Throwable e) {
                    ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
                }
            }
        });
        mUserMainReceiveOrderItemFinish.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {

                    MessageDialog.show("提示", "确定完成订单？", "确定", "取消")
                            .setCancelable(false)
                            .setOkButtonClickListener(new OnDialogButtonClickListener<MessageDialog>() {
                                @Override
                                public boolean onClick(MessageDialog dialog, View v) {
                                    try {

                                        WaitDialog.show("请稍等...");
                                        Beans beansIn = new Beans();
                                        beansIn.getJsonObject()
                                                .put("phone", AppParams.getInstance().appCurrentUser.getJsonObject()
                                                        .getString("phone"));
                                        beansIn.getJsonObject()
                                                .put("ordernum", bean.getJsonObject()
                                                        .getString("ordernum"));
                                        AppParams.getNewNetWork()
                                                .setInterface(new NetWorkInterface() {
                                                    @Override
                                                    public int success(String msg) {
                                                        try {
                                                            JSONObject msgFromServer = JSON.parseObject(msg);
                                                            if (Objects.equals(msgFromServer.getString("result"), "成功")) {
                                                                Message message = new Message();
                                                                message.what = 3;
                                                                UserMainProfileMyOrder userMainProfileMyOrder = (UserMainProfileMyOrder) AppParams.getInstance().sysfragmentmanager.findFragmentByTag("UserMainProfileMyOrder");
                                                                if (userMainProfileMyOrder != null) {
                                                                    userMainProfileMyOrder.handler.sendMessage(message);

                                                                }
                                                            }
                                                        } catch (Throwable e) {
                                                            ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
                                                        }
                                                        return 0;
                                                    }

                                                    @Override
                                                    public int failed(String msg) {
                                                        return 0;
                                                    }
                                                })
                                                .execute(AppParams.getInstance().baseUrl + "/orderFinish", bean.getJsonObject()
                                                        .toJSONString());
                                    } catch (Throwable e) {
                                        ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
                                    }
                                    return false;
                                }
                            });

                } catch (Throwable e) {
                    ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
                }
            }
        });
        mUserMainReceiveOrderItemEvaluate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {


                    MessageDialog.build(new OnBindView<MessageDialog>(R.layout.fragment_user_main_evaluate) {
                        @Override
                        public void onBind(MessageDialog dialog, View v) {
                            try {

                                TextView mUserMainEvaluateHead;
                                ImageView mUserMainEvaluateStars1;
                                ImageView mUserMainEvaluateStars2;
                                ImageView mUserMainEvaluateStars3;
                                ImageView mUserMainEvaluateStars4;
                                ImageView mUserMainEvaluateStars5;
                                TextView mUserMainEvaluateStarsSubmit;
                                mUserMainEvaluateHead = v.findViewById(R.id.user_main_evaluate_head);
                                mUserMainEvaluateStars1 = v.findViewById(R.id.user_main_evaluate_stars_1);
                                mUserMainEvaluateStars2 = v.findViewById(R.id.user_main_evaluate_stars_2);
                                mUserMainEvaluateStars3 = v.findViewById(R.id.user_main_evaluate_stars_3);
                                mUserMainEvaluateStars4 = v.findViewById(R.id.user_main_evaluate_stars_4);
                                mUserMainEvaluateStars5 = v.findViewById(R.id.user_main_evaluate_stars_5);
                                mUserMainEvaluateStarsSubmit = v.findViewById(R.id.user_main_evaluate_stars_submit);

                                mUserMainEvaluateStars1.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        try {
                                            mUserMainEvaluateStars1.setSelected(true);
                                            mUserMainEvaluateStars2.setSelected(false);
                                            mUserMainEvaluateStars3.setSelected(false);
                                            mUserMainEvaluateStars4.setSelected(false);
                                            mUserMainEvaluateStars5.setSelected(false);
                                        } catch (Throwable e) {
                                            ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
                                        }
                                    }
                                });
                                mUserMainEvaluateStars2.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        try {
                                            mUserMainEvaluateStars1.setSelected(true);
                                            mUserMainEvaluateStars2.setSelected(true);
                                            mUserMainEvaluateStars3.setSelected(false);
                                            mUserMainEvaluateStars4.setSelected(false);
                                            mUserMainEvaluateStars5.setSelected(false);
                                        } catch (Throwable e) {
                                            ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
                                        }
                                    }
                                });
                                mUserMainEvaluateStars3.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        try {
                                            mUserMainEvaluateStars1.setSelected(true);
                                            mUserMainEvaluateStars2.setSelected(true);
                                            mUserMainEvaluateStars3.setSelected(true);
                                            mUserMainEvaluateStars4.setSelected(false);
                                            mUserMainEvaluateStars5.setSelected(false);
                                        } catch (Throwable e) {
                                            ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
                                        }
                                    }
                                });
                                mUserMainEvaluateStars4.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        try {
                                            mUserMainEvaluateStars1.setSelected(true);
                                            mUserMainEvaluateStars2.setSelected(true);
                                            mUserMainEvaluateStars3.setSelected(true);
                                            mUserMainEvaluateStars4.setSelected(true);
                                            mUserMainEvaluateStars5.setSelected(false);
                                        } catch (Throwable e) {
                                            ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
                                        }
                                    }
                                });
                                mUserMainEvaluateStars5.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        try {
                                            mUserMainEvaluateStars1.setSelected(true);
                                            mUserMainEvaluateStars2.setSelected(true);
                                            mUserMainEvaluateStars3.setSelected(true);
                                            mUserMainEvaluateStars4.setSelected(true);
                                            mUserMainEvaluateStars5.setSelected(true);
                                        } catch (Throwable e) {
                                            ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
                                        }
                                    }
                                });


                                JSONObject data = JSON.parseObject(merchantInfo.getString("data"));

                                if (!StringUtils.isEmpty(data.getString("merchantName"))) {
                                    mUserMainEvaluateHead.setText("请对" + data.getString("merchantName") + "进行评价");
                                }
                                else {
                                    if (Objects.equals(data.getString("bodyType"), "企业") || Objects.equals(data.getString("bodyType"), "个体工商户")) {
                                        mUserMainEvaluateHead.setText("请对" + data.getString("companiesMerchantAbbreviation") + "进行评价");
                                    }
                                    else if (Objects.equals(data.getString("bodyType"), "个人")) {
                                        mUserMainEvaluateHead.setText("请对" + data.getString("individualMerchantAbbreviation") + "进行评价");
                                    }
                                }

                                mUserMainEvaluateStarsSubmit.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        try {
                                            if (!Tools.Deshak()) return;

                                        } catch (Throwable e) {
                                            ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
                                        }
                                    }
                                });


                            } catch (Throwable e) {
                                ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
                            }
                        }
                    }).show();


//                    Beans beansIn = new Beans();
//                    beansIn.getJsonObject()
//                            .put("phone", AppParams.getInstance().appCurrentUser.getJsonObject()
//                                    .getString("phone"));
//                    AppParams.getNewNetWork()
//                            .setInterface(new NetWorkInterface() {
//                                @Override
//                                public int success(String msg) {
//                                    try {
//                                        JSONObject msgFromServer = JSON.parseObject(msg);
//                                        if (Objects.equals(msgFromServer.getString("result"), "成功")) {
//
//                                        }
//                                    } catch (Throwable e) {
//                                        ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
//                                    }
//                                    return 0;
//                                }
//
//                                @Override
//                                public int failed(String msg) {
//                                    return 0;
//                                }
//                            })
//                            .execute(AppParams.getInstance().baseUrl + "/orderEvaluate", bean.getJsonObject()
//                                    .toJSONString());
                } catch (Throwable e) {
                    ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
                }
            }
        });
    }

    private void alipayHandler(Beans in) {
        try {
            Beans beansIn = new Beans();
            beansIn.getJsonObject()
                    .put("phone", AppParams.getInstance().appCurrentUser.getJsonObject()
                            .getString("phone"));
            beansIn.getJsonObject().putAll(in.getJsonObject());
            AppParams.getNewNetWork()
                    .setInterface(new NetWorkInterface() {
                        @Override
                        public int success(String msg) {
                            try {
                                JSONObject msgFromServer = JSON.parseObject(msg);
                                if (Objects.equals(msgFromServer.getString("result"), "成功")) {
                                    Message message = new Message();
                                    message.what = 1;
                                    UserMainProfileMyOrder userMainProfileMyOrder = (UserMainProfileMyOrder) AppParams.getInstance().sysfragmentmanager.findFragmentByTag("UserMainProfileMyOrder");
                                    if (userMainProfileMyOrder != null) {
                                        userMainProfileMyOrder.handler.sendMessage(message);

                                    }
                                }
                            } catch (Throwable e) {
                                ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
                            }
                            return 0;
                        }

                        @Override
                        public int failed(String msg) {

                            return 0;
                        }
                    })
                    .execute(AppParams.getInstance().baseUrl + "/alipayHandler", beansIn.getJsonObject()
                            .toJSONString());

        } catch (Throwable e) {
            ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
        }
    }

    @Override
    public void bindView(List list, Object bean) {
        if (bean instanceof Beans) {
            this.bean = (Beans) bean;
            initView();
        }


    }

    @SuppressLint({"ResourceAsColor", "SetTextI18n"})
    private void initView() {
        try {

            JSONObject data = JSON.parseObject(bean.getJsonObject().getString("data"));
            merchantInfo = JSON.parseObject(bean.getJsonObject().getString("merchantInfo"));
            JSONObject serviceType = JSON.parseObject(merchantInfo.getString("servicetype"));

            originBalance = Integer.parseInt(data.getString("serviceTimes")) * serviceType.getDoubleValue(data.getString("serviceType"));
            orderBalance = originBalance + couponsBalance;

            String filename = merchantInfo.getString("phone") + "_merchant_headshot_upload.png";
            Picasso.with(MainActivity.getInstance())
                    .load(AppParams.getInstance().uploadMediaLocationServer + "/" + filename)
                    .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)
                    .networkPolicy(NetworkPolicy.NO_CACHE)
                    .into(mUserMainProfileMyOrderItemMerchantHeadshot);
            mUserMainProfileMyOrderItemGametype.setText(data.getString("gameType"));
            mUserMainProfileMyOrderItemStatus.setText(bean.getJsonObject().getString("status"));
            mUserMainProfileMyOrderItemServicetype.setText("陪玩时长：" + data.getString("serviceTimes") + "小时");
            mUserMainProfileMyOrderItemStarttime.setText("开始时间：" + data.getString("month") + "月" + data.getString("day") + "日 " + data.getString("startTimeHour") + ":" + data.getString("startTimeMinute"));


            mUserMainReceiveOrderItemPay.setVisibility(View.GONE);
            mUserMainReceiveOrderItemStart.setVisibility(View.GONE);
            mUserMainReceiveOrderItemFinish.setVisibility(View.GONE);
            mUserMainReceiveOrderItemEvaluate.setVisibility(View.GONE);
            mUserMainReceiveOrderItemException.setVisibility(View.GONE);


            if (Objects.equals(bean.getJsonObject()
                    .getString("phone"), AppParams.getInstance().appCurrentUser.getJsonObject()
                    .getString("phone"))) {
                mUserMainProfileMyOrderItemOrdernum.setText("订单号：" + bean.getJsonObject()
                        .getString("ordernum"));


                mUserMainProfileMyOrderItem.setBackgroundResource(R.color.bk);
                mUserMainProfileMyOrderItemOrderBalance.setText("总金额：" + orderBalance + "元");


                if (Objects.equals(bean.getJsonObject().getString("status"), "待支付")) {
                    mUserMainReceiveOrderItemPay.setVisibility(View.VISIBLE);

                }
                else if (Objects.equals(bean.getJsonObject().getString("status"), "预约中")) {
                    mUserMainReceiveOrderItemStart.setVisibility(View.VISIBLE);
                    mUserMainReceiveOrderItemException.setVisibility(View.VISIBLE);

                }
                else if (Objects.equals(bean.getJsonObject().getString("status"), "陪玩中")) {
                    mUserMainReceiveOrderItemFinish.setVisibility(View.VISIBLE);
                    mUserMainReceiveOrderItemException.setVisibility(View.VISIBLE);
                }
                else if (Objects.equals(bean.getJsonObject().getString("status"), "已完成")) {
                    mUserMainReceiveOrderItemEvaluate.setVisibility(View.VISIBLE);
                }
            }
            else {
                mUserMainProfileMyOrderItemOrdernum.setText("订单号：" + bean.getJsonObject()
                        .getString("ordernum") + " 我的店铺");
                mUserMainReceiveOrderItemPay.setVisibility(View.GONE);
                mUserMainProfileMyOrderItem.setBackgroundResource(R.color.white);
                mUserMainProfileMyOrderItemOrderBalance.setText("总金额：" + orderBalance + "元(含平台服务费" + Tools.doubleFormat(orderBalance * AppParams.getInstance().percentage) + "元)");


            }


        } catch (Throwable e) {

            PopTip.show(e.getMessage());
            ExceptionUtils.getException(ExceptionUtils.getTraceInfo(), e);
        }
    }
}